<script>
function del_collection(url){
	 if(!confirm('Bạn có chắc muốn xóa dữ liệu này?')){
         return;
      }
     	$.ajax({
	        url: url,
	        type: 'GET',
	        error: function(){
	            alert('Error !');
	        },
	        success: function(success)
	        {
                        list_ajax('<?php echo $this->session->userdata('url_list_company');?>','');
  	        }
	    });
    }
</script>
<div class="topart">
    	<span class="left">
    		<font class="number">(<?php echo $this->company_model->get_count_all_company();?>)</font>
                    <a href="javascript:;">Loại điều hòa</a>   
                    <font class="line">|</font>
                <font class="number">(<?php echo $this->company_model->get_count_all_company('yes');?>)</font>
                    <a href="javascript:;"><font color="#0b9901">Kích hoạt</font></a>
                <font class="line">|</font>
                <font class="number">(<?php echo $this->company_model->get_count_all_company('no');?>)</font>
                    <a href="javascript:;"><font color="#c60001">Chưa kích hoạt</font></a>             
        </span>
        <span class="right1">
            <select id="limit" onchange="list_ajax('<?php echo base_url_admin('company/list_ajax/');?>')" style="width:50px;">
                    <option <?php if($limit == 5) echo 'selected="selected"';?> value="5">5</option>
                    <option <?php if($limit == 10) echo 'selected="selected"';?> value="10">10</option>
                    <option <?php if($limit == 20) echo 'selected="selected"';?> value="20">20</option>
                    <option <?php if($limit == 30) echo 'selected="selected"';?> value="30">30</option>
                    <option <?php if($limit == 50) echo 'selected="selected"';?> value="50">50</option>
                    <option <?php if($limit == 100) echo 'selected="selected"';?> value="100">100</option>
            </select>
            <div class="pagination">
                <?php echo $pagnav;?>
            </div>
        </span>

    </div>

<div class="tableout">
	<div class="title1">
            <div class="column" style="width:2%;"><input type="checkbox" name="check_all" value="" id="check_all" /></div>
            <div class="column" style="width:60%;">Tên công ty</div>
            <div class="column" style="width:20%;">Order</div>
            <div class="column" style="width:10%;">Trạng thái</div>
        </div>
        <?php if($all_company):?>
        <?php
        $n = 0;
        foreach($all_company as $num => $collec):
          $n++;
          $next_order=$num;
          $back_order=$num+1;
          if($n>1){
          	$next_order = intval($num-1);
          }
          if($n==count($all_company)){
          	$back_order = intval($num);
          }
         ?>
	         <div class="linecate">
                <div class="column" style="width:2%;"><input type="checkbox" name="id[]" id="id[]" value="<?php echo $collec->id?>" /></div>
	            <div class="column" style="width:60%;" onmouseover="Hovercat('<?php echo $n?>')" onmouseout="Outcat('<?php echo $n?>')">
	            	<a class="art" href="javascript:void(0)" class="art" title="<?php echo $collec->name;?>"><?php echo cut_string($collec->name,50)?></a><br />
	                <div class="action" id="neocat-<?php echo $n?>">
	                    <img src="<?php echo admin_img("edit.gif")?>" />
                            <a id="xxx<?php echo $collec->id;?>" href="javascript:void(0)" onclick ="edit(<?php echo $collec->id;?>);">Sửa</a>|
                             <?php if($collec->status=='no'){?>
		                      <img src="<?php echo admin_img("active.png")?>" class="png" /><a href="javascript:;" onclick="change_status('<?php echo base_url_admin("company/change_status")?>','yes',<?php echo $collec->id?>);">Kích hoạt</a>
		                      <?php }else{?>
		                      <img src="<?php echo admin_img("unactive.png")?>" class="png" /><a href="javascript:;" onclick="change_status('<?php echo base_url_admin("company/change_status")?>','no',<?php echo $collec->id?>);">Hủy kích hoạt</a>
		                     <?php }?>
	                     	<img src="<?php echo admin_img("delete.gif")?>" class="png" /><a href="javascript:;" onclick="del_collection('<?php echo base_url_admin("company/del/".$collec->id)?>');">Xóa</a>
	                </div>
	            </div>
				<div class="column" style="width:20%;">
                    <input type="text" name="lib[<?php echo $num?>][order]" id="lib_<?php echo $num?>" value="<?php echo $collec->order?>" style="width:45px; float:left;" onkeypress="enter_go(event);" />
                    <span class="updown">
                        <a href="javascript:;" onclick="order_step('lib_<?php echo $num?>',<?php echo $all_company[$next_order]->order?>);">
                            <img src="<?php echo admin_img("up.gif")?>" title="up" />
                        </a>
                        <a href="javascript:void(0);" onclick="order_step('lib_<?php echo $num?>',<?php echo $all_company[$back_order]->order?>);">
                            <img src="<?php echo admin_img("down.gif")?>" title="down" />
                        </a>
                    </span>
                </div>     
                
                <div class="column" style="width:10%;">
                    <?php if($collec->status=='yes'){?>
	                      <a href="javascript:;" onclick="change_status('<?php echo base_url_admin("company/change_status")?>','no',<?php echo $collec->id?>);"><img src="<?php echo admin_img("active.png")?>" class="png" /></a>
	                      <?php }else{?>
	                      <a href="javascript:;" onclick="change_status('<?php echo base_url_admin("company/change_status")?>','yes',<?php echo $collec->id?>);"><img src="<?php echo admin_img("unactive.png")?>" class="png" /></a>
	            <?php }?>
	            </div>          
	        </div>
        <input type="hidden" name="lib[<?php echo $num?>][id]" value="<?php echo $collec->id?>" />
        <input type="hidden" id="lib[<?php echo $num?>][old_order]" name="lib[<?php echo $num?>][old_order]" value="<?php echo $collec->order?>" />        
        <?php endforeach; echo "</div>"; //last div close ?>
         <?php else:?>
        <div class="linecate2">
        	<b>Dữ liệu hiện tại đang rỗng!</b>
        </div>
        <?php endif;?>
        </form>
        <span class="right1">
            <div class="pagination">
                   <?php echo $pagnav;?>
            </div>
        </span>
    </div>
</div>
</form><!-- End form action -->
<div id="div_action" class="white_content"><!-- Content action ajax --></div>
<div id="fade" class="black_overlay"></div>
